home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / newtsr1.zip / NEWTSR1.ASM < prev   
Assembly Source File  |  1987-01-22  |  3KB  |  99 lines

  1. NAME    install_tsr
  2. ;
  3. DGROUP    GROUP    DATA
  4.  
  5. PGROUP    GROUP    PROG
  6.  
  7. PROG    SEGMENT BYTE PUBLIC 'PROG'
  8.     ASSUME    CS:PGROUP,DS:DGROUP,es:nothing
  9.  
  10.     PUBLIC    MAIN            ;NOTE: ALTHOUGH C88 USES A TRAILING
  11.                     ;UNDERSCORE ON PUBLICS, THESE ARE
  12.                     ;DELETED IN .OBJ FORMAT.
  13.     extrn foo:near,fee:near,last_data:near
  14. MAIN    PROC    NEAR
  15.     PUSH    DS            ;SAVE OLD DS
  16.     PUSH    CS
  17.     POP    DS            ;SET UP DS:DX TO
  18.     MOV    DX,OFFSET pgroup:PROC_INT    ;INITIALIZE FUNCTION CALL 
  19.     MOV    AL,0E0H            ;INTERRUPT E0H
  20.     MOV    AH,25h            ;USE DOS CALL 25H
  21.     INT    21H
  22.     ;now we find the size of this program and data area
  23.     ;so it can be passed to the terminate and stay resident function
  24.     pop    ds            ;restore original ds
  25.     mov    dx,ds            ;put in dx for use later
  26.     mov    cs:saveds,dx        ;save ds where we can always find it
  27.     mov    ax,offset dgroup:last_data    ;get marker of end of data area
  28.     mov    cl,4            ;get cl ready for para. computation
  29.     push    ax            ;end of data marker
  30.     and    ax,0fh            ;check for additional paragraph
  31.     jz    all_ok            ;last digit zero, ok
  32.     pop    ax            ;last digit non zero,
  33.     shr    ax,cl            ;compute paragraph
  34.     inc    ax            ;add one
  35.     jmp    get_out
  36. all_ok:                    ;otherwise,stick with original end
  37.     pop    ax
  38.     shr    ax,cl
  39. get_out:
  40.     add    dx,ax            ;now dx has end paragraph number
  41.     ;es has paragraph number of initial allocation block
  42.     mov    ax,es
  43.     sub    dx,ax            ;difference between end paragraph # and
  44. ;                    ;# of initial alloc. block is pgm size
  45.     mov    ah,31H            ;this is passed to term and stay res.
  46.     int    21H            ;function
  47. MAIN    ENDP
  48. ;
  49. ;
  50. ;This procedure is the software interrupt function handler
  51. ;
  52. ;
  53. proc_int    proc    near
  54.     push    ax            ;save all regs
  55.     push    bx
  56.     push    cx
  57.     push    dx
  58.     push    si
  59.     push    di
  60.     push    bp
  61.     push    ds
  62.     push    es
  63.     mov    bx,cs:saveds        ;restore original ds
  64.     mov    ds,bx
  65.     sti                ;allow interrupts to happen
  66.     xor    ah,ah            ;calculate offset into vector table
  67.     shl    al,1
  68.     mov    si,ax
  69.     ;
  70.     call    cs:[si+offset vec_tab]    ;call the function
  71.     ;
  72.     pop    es            ;restore all regs
  73.     pop    ds
  74.     pop    bp
  75.     pop    di
  76.     pop    si
  77.     pop    dx
  78.     pop    cx
  79.     pop    bx
  80.     pop    ax
  81.     iret                
  82. proc_int    endp
  83. ;
  84. ;
  85. saveds    dw    ?
  86. VEC_TAB    DW    OFFSET pgroup:foo
  87.     DW    OFFSET pgroup:fee
  88. PROG    ENDS
  89. ;
  90. DATA    SEGMENT    WORD PUBLIC 'DATA'
  91. DATA    ENDS
  92.     END
  93. ;
  94. ;
  95. ;
  96. ;
  97. ;
  98. ;
  99.